//
//  GZBaseController.m
//  GongZheng
//
//  Created by huan on 2018/4/26.
//  Copyright © 2018年 huan. All rights reserved.
//

#import "GZBaseController.h"

@interface GZBaseController ()

@property (nonatomic, assign) UIStatusBarStyle statusBarStyle;
@property (nonatomic, assign) BOOL statusBarHidden;
@property (nonatomic, assign) BOOL changeStatusBarAnimated;


@end

@implementation GZBaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor backgroundColor];
    [self.view addSubview:self.navBar];
    self.tabBarController.tabBar.hidden = YES;
    @weakify(self);
    [[self.navBar.leftClickSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
        @strongify(self);
        [self navigationLeftButtonAction];
    }];
    [[self.navBar.rightClickSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
        @strongify(self);
        [self navigationRightButtonAction];
    }];
}

#pragma mark - system
- (UIStatusBarStyle)preferredStatusBarStyle {
    if (self.statusBarStyle) {
        return self.statusBarStyle;
    } else {
        return UIStatusBarStyleLightContent;
    }
}

- (BOOL)prefersStatusBarHidden {
    return self.statusBarHidden;
}

#pragma mark - private
-(void)changeStatusBarStyle:(UIStatusBarStyle)statusBarStyle
            statusBarHidden:(BOOL)statusBarHidden
    changeStatusBarAnimated:(BOOL)animated {
    self.statusBarStyle = statusBarStyle;
    self.statusBarHidden = statusBarHidden;
    if (animated) {
        [UIView animateWithDuration:0.25 animations:^{
            [self setNeedsStatusBarAppearanceUpdate];
        }];
    }else {
        [self setNeedsStatusBarAppearanceUpdate];
    }
}

- (void)setTitleString:(NSString *)titleString {
    _titleString = [titleString copy];
    self.navBar.titleString = titleString;
}

- (void)setNotShowLeft:(BOOL)notShowLeft {
    _notShowLeft = notShowLeft;
    self.navBar.notShowLeft = notShowLeft;
}

- (void)setShowRight:(BOOL)showRight {
    _showRight = showRight;
    self.navBar.showRight = showRight;
}

- (void)recoverKeyboard {
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
//    @weakify(self);
//    [tap.rac_gestureSignal subscribeNext:^(id x) {
//        @strongify(self);
//        [self.view endEditing:YES];
//    }];
//    [self.view addGestureRecognizer:tap];
}

- (void)refreshData{
    
}
#pragma mark - 屏幕旋转
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotate {
    return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

#pragma mark - layzLoad
- (GZNavigationBar *)navBar {
    if (!_navBar) {
        _navBar = [GZNavigationBar navigationBar];
    }
    return _navBar;
}


#pragma mark - delegate method
- (void)eage_bindViewModel {}

- (void)eage_addSubviews {}

- (void)eage_getNewData {}

- (BOOL)uiDeviceIsX {
    if (SCREEN_HEIGHT == 812) { // iphoneX
        return YES;
    }
    return NO;
}

- (void)navigationLeftButtonAction {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)navigationRightButtonAction {}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
